package com.yuexiang.melodyhub.common.result;

import lombok.Data;

@Data
public class ResultData<T> {

    private int code;

    private String message;

    private T data;

    private long timestamp;

    public ResultData() {
    }

    public ResultData(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> ResultData<T> success(T data) {
        return new ResultData<>(ReturnCode.RC200.getCode(), ReturnCode.RC200.getMsg(), data);
    }

    public static <T> ResultData<T> fail(int code, String message) {
        return new ResultData<>(code, message, null);
    }

}
